<?

require_once("mysql.php");

@session_start();

function find_or_create_user() {

    $q = "SELECT id FROM user WHERE id=XXX";
    $q = str_replace('XXX', $_SESSION['userid'], $q);
	
	$r = MYSQL_Q($q);
	$a = mysql_fetch_array($r);

    if (empty($a)) { // new user
	
         $q = "INSERT INTO user (id, name,token) VALUES (ID, 'NAME', 'TOKEN')";
		 $q = str_replace(array("ID", "NAME", "TOKEN"), array($_SESSION['userid'], $_SESSION['username'], $_SESSION['token']), $q);
		 MYSQL_Q($q);
	
	} else {  // returning user
	
	
	}
}

?>